package com.lian.pet.controller;

import com.lian.pet.common.basic.response.AppResp;
import com.lian.pet.domain.dto.AddVaccinesDTO;
import com.lian.pet.domain.dto.QueryVaccinesDTO;
import com.lian.pet.domain.vo.VaccinesVO;
import com.lian.pet.service.VaccinesService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequestMapping("vaccines")
@RestController
@AllArgsConstructor
public class VaccinesController {
    private final VaccinesService vaccinesService;

    /**
     * 新增疫苗
     * @param req
     */
    @PostMapping("/add")
    public AppResp<Void> addVaccines(@RequestBody AddVaccinesDTO req) {
        vaccinesService.addVaccines(req);
        return AppResp.succeed(null);
    }

    /**
     * 查询疫苗列表
     * @param req
     * @param name
     * @return
     */
    @PostMapping("/queryList")
    public AppResp<List<VaccinesVO>> queryPets(@RequestBody QueryVaccinesDTO req,@RequestParam("name")String name) {
        return AppResp.succeed(vaccinesService.queryVaccines(req,name));
    }

    /**
     * 查询疫苗信息
     * @param id
     * @return
     */
    @GetMapping("/getById")
    public AppResp<VaccinesVO> getVaccinesById(@RequestParam("id") Integer id) {
        return AppResp.succeed(vaccinesService.getVaccines(id));
    }

    @GetMapping("/deleteById")
    public AppResp<Integer> deleteById(@RequestParam("id") Integer id) {
        vaccinesService.deleteVaccines(id);
        return AppResp.succeed(1);
    }
}
